package com.neusoft.elmboot.mapper;

import com.neusoft.elmboot.po.Comment;
import com.neusoft.elmboot.po.Food;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;
import java.util.List;

@Mapper
public interface FoodMapper {

    @Select("select * from food where businessId=#{businessId} order by foodId")
    public List<Food> listFoodByBusinessId(Integer businessId);

    @Select("select * from food where foodId=#{foodId}")
    public Food getFoodById(Integer foodId);

  	@Delete("delete from food where foodId=#{foodId} and businessId=#{businessId} ")
    public int removeFoodByBusinessIdById(Integer foodId,Integer businessId);

    @Update("update food set foodName = #{foodName}, foodPrice = #{foodPrice}, foodExplain = #{foodExplain} WHERE foodId = #{foodId}")
    public int updateFood(Food food);
    
    @Insert("insert into food (foodName, foodExplain, foodPrice, businessId, foodImg) values (#{foodName}, #{foodExplain}, #{foodPrice}, #{businessId}, #{foodImg})")
    @Options(useGeneratedKeys = true, keyProperty = "foodId")
    public int addFood(Food food);
}
